import sys

import pymongo

from pymongo import errors as mongoErrors

class DBConnect:
    
    def __init__(self, host="localhost", port=27017, db="rbs"):
    
        self.dbserver = host
        self.dbport = port
        self.dbname = db
        #return pymongo.MongoClient(host="mongodb://" + getConfiguration('rbs')['dbServer'] + ":" + getConfiguration('rbs')['dbPort'], auto_start_request=False, safe=True, j=True)
        #return pymongo.MongoClient(host="mongodb://" + dbserver + ":" + dbport, auto_start_request=False, safe=True, j=True)
        
        conn = pymongo.MongoClient(host=self.dbserver, port=self.dbport, auto_start_request=False, safe=True, j=True)
        
        db = conn[self.dbname]
        
        return db

    def connectCollection(collname)
    
def main():
    try:
       c = DBConnect()
    except mongoErrors.ConnectionFailure, e:
        print "Exception: %s" % (e)

if __name__ == '__main__':
    main()

